﻿using System.Web;

namespace Nydus.WebForms.FrontendModel
{
    public class PresenterBuilder
    {
        public static PresenterBuilder Current
        {
            get { return instance; }
            set { instance = value; }
        }

        public IPresenterFactory PresenterFactory { get; set; }

        public PresenterBuilder(IPresenterFactory factory)
        {
            if (factory != null) 
                PresenterFactory = factory;
            else
                PresenterFactory = new DefaultPresenterFactory();
        }

        public object GetPresenter(HttpContextBase httpContextBase, BasePage page)
        {
            return PresenterFactory.GetPresenter(httpContextBase, page);
        }

        private static PresenterBuilder instance = new PresenterBuilder(null);
    }
}
